package com.ruoyi.tactics.algorithm;

import com.ruoyi.tactics.ZodiacResult;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 五不中
 */
public class WBZAlgorithm extends AbstractAlgorithm {

    @Override
    public Boolean isWin(ZodiacResult zodiacResult, String... code) {
        List<Integer> pms = zodiacResult.getPm();
        return isContains(pms, Integer.parseInt(code[0]), Integer.parseInt(code[1]), Integer.parseInt(code[2]), Integer.parseInt(code[3]), Integer.parseInt(code[4]));
    }

    private Boolean isContains(List<Integer> pms, Integer... codes) {
        Set<Integer> pmSet = new HashSet<>();
        pmSet.addAll(pms);
        Set<Integer> codeSet = new HashSet<>();
        codeSet.addAll(Arrays.asList(codes));
        pmSet.retainAll(codeSet);
        return pmSet.size() == 0;
    }

    public static void main(String[] args) {
        WBZAlgorithm algorithm = new WBZAlgorithm();
        ZodiacResult zodiacResult = new ZodiacResult();
        zodiacResult.setPm(Arrays.asList(1, 2, 3, 4, 5));
        System.out.println(algorithm.isWin(zodiacResult, "2", "9", "6","7","10"));
        System.out.println(algorithm.isWin(zodiacResult, "8", "9", "6","7","10"));
    }

}
